<%@ page language="java" import="com.alibaba.fastjson.JSONArray" pageEncoding="UTF-8" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.general.Util" %>
<%--在线考试批阅提交分数--%>
<%
    JSONObject jsonData = new JSONObject();
    RecordSet rs = new RecordSet();
    BaseBean baseBean = new BaseBean();
    String formtable = "formtable_main_286";//在线考试答题
    String requestid = Util.null2String(request.getParameter("requestid"));
    baseBean.writeLog(">>>>saveScore_Ajax>>>requestid="+requestid);
    String mainid = getFieldValByname("id",requestid,formtable);
    baseBean.writeLog(">>>>saveScore_Ajax>>>mainid="+mainid);
    String result = Util.null2String(request.getParameter("result"));
    baseBean.writeLog(">>>>saveScore_Ajax>>>result="+result);
    JSONObject resultJSON = JSONObject.parseObject(result);
    JSONArray jdtList = JSONArray.parseArray(resultJSON.getString("jdt"));
    if(jdtList.size()>0){
        for(int i=0;i<jdtList.size();i++) {
            String xh =  jdtList.getJSONObject(i).getString("xh").substring(2);
            int newxh = Util.getIntValue(xh)+1;
            String score =  jdtList.getJSONObject(i).getString("score");
            baseBean.writeLog(">>>>saveScore_Ajax>>>score="+score+",newxh="+newxh);
            rs.executeUpdate("update "+formtable+"_dt4 set df='"+score+"' where mainid=? and px=?",mainid,newxh);
        }
    }
    jsonData.put( "status", true);
    out.print( jsonData.toJSONString() );
%>

<%!
    /**
     * 获取表单字段
     */
    public String getFieldValByname(String filename, String requestid, String formtable) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select " + filename + " from " + formtable + " where requestid=?", requestid);
        rs.next();
        return Util.null2String(rs.getString(1));
    }

%>




